package com.jfok.server.hibernate.system;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;


import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.jfok.server.common.FileOperate;
import com.jfok.server.common.annotation.FieldDefine;
import com.jfok.server.common.annotation.TableDefine;
import com.jfok.server.core.report.GroupFieldDefine;
import com.jfok.server.hibernate.systemset._ModuleApprove;
import com.jfok.shared.module.ModuleConstants;


@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@SuppressWarnings("serial")
@Entity
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@TableDefine(group = "系统模块", id = 9902, title = "系统模块")
public class _Module implements _IModuleControlInterface, Serializable {

	public static final String MODULEID = "tf_moduleId";
	public static final String MODULENAME = "tf_moduleName";

	@Id
	@FieldDefine(title = "模块ID号", number = 10)
	@Column(nullable = false, length = 10)
	private String tf_moduleId; // 模块ＩＤ，模块序号

	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "tf_moduleGroupId")
	@FieldDefine(title = "模块分组", number = 20)
	private _ModuleGroup tf_ModuleGroup;

	@FieldDefine(title = "模块标识", number = 30)
	@Column(nullable = false, length = 50, updatable = false)
	private String tf_moduleName; // 模块英文名称

	@FieldDefine(title = "模块名称", nameField = true, number = 40)
	@Column(nullable = false, length = 50)
	private String tf_title; // 模块中文名称

	@FieldDefine(title = "模块简称", number = 50)
	@Column(length = 20)
	private String tf_shortname; // 简称

	@FieldDefine(title = "英文简称", number = 60)
	@Column(length = 20)
	private String tf_englishname; // 英文简称，在新增序号的时候，可以把这字母加进去

	@FieldDefine(title = "表名", number = 70)
	@Column(length = 50)
	private String tf_tableName;

	@FieldDefine(title = "主键", number = 80)
	@Column(nullable = false, length = 50)
	private String tf_primaryKey;// 模块主键

	@FieldDefine(title = "显示标志字段", number = 81)
	@Column(nullable = false, length = 50)
	private String tf_nameFields;// 模块主要关键内容的字段，如合同的是合同名称，部门的是部门名称

	@FieldDefine(title = "记录标题tpl", number = 82, remark = "如果显示标志字段不能描述记录,需要设置此内容")
	@Column(length = 200)
	private String tf_titleTpl;// 模块主要关键内容的字段，如合同的是合同名称，部门的是部门名称

	@FieldDefine(title = "编码字段", number = 91)
	@Column(length = 50)
	private String tf_codeField;// 模块编码字段，如果有的话


	@FieldDefine(title = "顺序号字段", number = 97)
	@Column(length = 50)
	private String tf_orderField;// 模块编码字段，如果有的话
	
	@FieldDefine(title = "日期字段", number = 92)
	@Column(length = 50)
	private String tf_dateField;

	@FieldDefine(title = "年度字段", number = 93)
	@Column(length = 50)
	private String tf_yearfield;

	@FieldDefine(title = "月度字段", number = 94)
	@Column(length = 50)
	private String tf_monthField;

	@FieldDefine(title = "季度字段", number = 95)
	@Column(length = 50)
	private String tf_seasonField;

	@FieldDefine(title = "文件字段", number = 96)
	@Column(length = 50)
	private String tf_fileField;

	@FieldDefine(title = "主页上顺序", number = 99)
	@Column(length = 50)
	private String tf_homePageTag;

	@FieldDefine(title = "模块描述", number = 100)
	@Column(length = 50)
	private String tf_description;

	@FieldDefine(title = "请求地址", number = 110)
	@Column(nullable = false, length = 50)
	private String tf_requestMapping;// 系统中后台服务的调用接入点 user.do,employee.do 等

	@FieldDefine(title = "图标地址", number = 120)
	@Column(length = 50)
	private String tf_iconURL;

	@FieldDefine(title = "默认排序字段", number = 130)
	private String tf_defaultOrderField;

	@FieldDefine(title = "行操作", remark = "新增及修改操作都行内完成", number = 140)
	@Column(nullable = false)
	private Boolean tf_isInlineOper;

	// 如部门编码为 2,2,2,2,2
	@FieldDefine(title = "编码级次", remark = "如果设置了编码级次，则主键的长度必须是此级次中的，并且必须有父级编码存在", number = 150)
	@Column(length = 50)
	String tf_codeLevel;

	@FieldDefine(title = "联动模块", remark = "在本模块的数据增删改后，打开的联动模块都要刷新数据。", number = 155)
	@Column(length = 200)
	private String tf_linkedModule;

	@FieldDefine(title = "可用", number = 160)
	@Column(nullable = false)
	private Boolean tf_isEnable = false;

	@FieldDefine(title = "可浏览", number = 170)
	@Column(nullable = false)
	private Boolean tf_hasBrowse = false;

	@FieldDefine(title = "可增加", number = 180)
	@Column(nullable = false)
	private Boolean tf_hasInsert = false;

	@FieldDefine(title = "可修改", number = 190)
	@Column(nullable = false)
	private Boolean tf_hasEdit = false;

	@FieldDefine(title = "可删除", number = 200)
	@Column(nullable = false)
	private Boolean tf_hasDelete = false;

	@FieldDefine(title = "可执行", number = 210)
	@Column(nullable = false)
	private Boolean tf_hasExec = false;

	@FieldDefine(title = "可审核", number = 220)
	@Column(nullable = false)
	private Boolean tf_hasAuditing = false;

	@FieldDefine(title = "可审批", number = 230)
	@Column(nullable = false)
	private Boolean tf_hasApprove = false;

	@FieldDefine(title = "可支付", number = 240)
	@Column(nullable = false)
	private Boolean tf_hasPayment = false;

	@FieldDefine(title = "有附件", number = 250)
	@Column(nullable = false)
	private Boolean tf_hasAddition = false; // 是否需要附件

	@FieldDefine(title = "可权限设置", remark = "用户可对此模块设置权限，选定的才可以浏览与操作", number = 260)
	@Column(nullable = false)
	private Boolean tf_canLimit = false; // 此模块是否能进行权限设置

	@FieldDefine(title = "Excel导入", remark = "是否可以通过Excel导入新增记录", number = 270)
	@Column(nullable = false)
	private Boolean tf_allowInsertExcel = false;

	@FieldDefine(title = "Excel修改", remark = "是否可以导出的Excel修改后再导入", number = 280)
	@Column(nullable = false)
	private Boolean tf_allowEditExcel = false;

	@FieldDefine(title = "可图表", number = 290)
	@Column(nullable = false)
	private Boolean tf_hasChart = false;

	@FieldDefine(title = "系统模块", number = 300, remark = "如果是系统模块，用户没有浏览权限，就不把模块定义发送到前端")
	@Column(nullable = false)
	private Boolean tf_isSystem = false;

	@FieldDefine(title = "查询条件顺序号", number = 310, remark = "此模块放在综合查询的条件选择栏中的顺序")
	private Integer tf_searchCondOrder;

	@FieldDefine(title = "备注", number = 800)
	private String tf_remark;

	@Transient
	private List<_ModuleField> moduleFields;
	// 本模块定义的附加字段，包括manytoOne的父模块，以及child模块的聚合字段

	// 本模块的审批信息的字义
	@Transient
	private List<_ModuleApprove> moduleApproves;

	@Transient
	private List<_ModuleAdditionField> moduleAdditionFields;

	@Transient
	private List<_ModuleFormScheme> moduleFormSchemes;

	@Transient
	private List<_ModuleGridScheme> moduleGridSchemes;

	@Transient
	private List<_ModuleDetailScheme> moduleDetailSchemes;

	@Transient
	private List<_ModuleGridNavigate> moduleGridNavigates;

	@Transient
	private List<_ModuleExcelReport> moduleExcelReports;

	// 单条记录的导入设置
	@Transient
	private List<_ModuleExcelRecordAdd> moduleExcelRecordAdds;

	// 模块单条记录的打印的设置
	@Transient
	private List<_PrintScheme> recordPrintSchemes;

	// 附加的功能设置
	@Transient
	private List<_ModuleAdditionFunction> moduleAdditions;

	//所有的本模块可以进行分组设置的定义
  @Transient
	private List<GroupFieldDefine> groupFieldDefines;
	
	// 保存此模块的当前的idNameMaps,如果有manyToOne模块，可以放在其下拉框里,
	@JsonIgnore
	@Transient
	private Map<String, String> idNameMap;

	@Transient
	private List<_ModuleSubToolbar> moduleSubToolbar;
	
	@JsonIgnore
	@Transient
	private List<_Module> parents;

	@JsonIgnore
	@Transient
	private List<_Module> parentOneToOnes;

	@JsonIgnore
	@Transient
	private List<_Module> childOneToOnes;

	// 可以加入导航的本层的manytoone模块
	@JsonIgnore
	@Transient
	private List<_Module> navigateParents;

	@JsonIgnore
	@Transient
	private List<_Module> childs;

	// 包括所有的manytoone和onetoone
	@Transient
	private List<String> childNames;

	// @Transient
	// private ApproveModuleInfo approveModuleInfo;

	// 只在后台作比较，不传到前台
	@JsonIgnore
	@Transient
	private List<_ModuleFieldConstraint> moduleFieldConstraints = null;

	public _Module() {

	}

	// private String tf_parentModuleId;
	// private Integer tf_parentDisplayOrder; // 已模块在父模块中的按钮的显示顺序号
	// private String tf_childModuleIds; // 本模块的子模块，有些模块有二个父，需要在此设置
	// private Boolean tf_departmentLimit; // 是否要加入全局部门限制
	// private String tf_leftTree; // 是否有显示在左边的树形导航栏，如部门， 部门＋工程，部门＋ 工程＋标段
	// private Boolean tf_hasAddition; // 是否需要附件
	// private String tf_otherSetting;
	// private String tf_printDefine; // 定义的直接在系统中打印模板
	@Override
	public String toString() {
		return "_Module [tf_moduleId=" + tf_moduleId + ", tf_moduleGroup=" + tf_ModuleGroup
				+ ", tf_moduleName=" + tf_moduleName + ", tf_title=" + tf_title + ", tf_shortname="
				+ tf_shortname + ", tf_englishname=" + tf_englishname + "]";
	}

	public void setAllDisable() {
		tf_isEnable = false;
		tf_hasBrowse = false;
		tf_hasInsert = false;
		tf_hasEdit = false;
		tf_hasDelete = false;
		tf_hasExec = false;
		tf_hasAuditing = false;
		tf_hasApprove = false;
		tf_hasPayment = false;
	}

	// 根据id 返回modulefiles 中的字段
	public _ModuleField getModuleFieldByFieldId(Integer fieldId) {
		for (_ModuleField field : moduleFields)
			if (field.getTf_fieldId().equals(fieldId)) {
				return field;
			}
		return null;
	}

	// 根据id 返回moduleaddition 中的字段
	public _ModuleAdditionField getModuleAdditionFieldByFieldId(Integer fieldId) {
		for (_ModuleAdditionField field : moduleAdditionFields)
			if (field.getTf_fieldId().equals(fieldId)) {
				return field;
			}
		return null;
	}

	// 根据id 返回modulefiles 中的字段
	public _ModuleField getModuleFieldByFieldName(String fieldName) {
		for (_ModuleField field : moduleFields)
			if (field.getTf_fieldName().equals(fieldName)) {
				return field;
			}
		return null;
	}

	// 返回modulefiles 的primarykdy字段
	@JsonIgnore
	public _ModuleField getPrimaryKeyField() {
		for (_ModuleField field : moduleFields)
			if (field.getTf_fieldName().equals(tf_primaryKey)) {
				return field;
			}
		return null;
	}

	// 返回modulefiles 的primarykdy字段
	@JsonIgnore
	public _ModuleField getNameField() {
		for (_ModuleField field : moduleFields)
			if (field.getTf_fieldName().equals(tf_nameFields)) {
				return field;
			}
		return null;
	}

	
	@JsonIgnore
	public List<_ModuleGridNavigate> getAllNavigatePaths() {
		List<_ModuleGridNavigate> result = new ArrayList<_ModuleGridNavigate>();
		getNavigateParentPaths(result, null);
		result.addAll(getNavigateFields());
		return result;
	}

	
	@JsonIgnore
	public List<_ModuleGridNavigate> getNavigateFields() {
		List<_ModuleGridNavigate> result = new ArrayList<_ModuleGridNavigate>();
		if (moduleFields != null)
			for (_ModuleField field : moduleFields) {
				if (field.getTf_showNavigatorTree() && field.isBaseField())
					result.add(new _ModuleGridNavigate(field.getTf_fieldName(), field.getTf_title())); // true
			}
		return result;
	}

	@JsonIgnore
	public _ModuleField getFieldWithAsAndFieldName(String fieldName) {
		for (_ModuleField field : moduleFields) {
			if ((getTableAsName() + "." + field.getTf_fieldName()).equals(fieldName))
				return field;
		}
		return null;
	}

	
	@JsonIgnore
	public List<_ModuleGridNavigate> getCanNavigatePaths() {
		List<_ModuleGridNavigate> result = new ArrayList<_ModuleGridNavigate>();
		getCanNavigateParentPaths(result, null);
		return result;
	}

	
	@JsonIgnore
	public void getCanNavigateParentPaths(List<_ModuleGridNavigate> allPath,
			_ModuleGridNavigate parent) {
		// List<List<String>> result = new ArrayList<List<String>>();
		if (getParents().size() > 0) {
			// 如果这个节点有父接点，那么把这个删了，要加入的父接点－－祖父接点
			allPath.remove(parent);
			for (_Module pmodule : getParents()) {
				_ModuleGridNavigate p = new _ModuleGridNavigate(pmodule.getTf_moduleName()
						+ (parent == null ? "" : "--" + parent.getTf_fields()), pmodule.getTf_title()
						+ (parent == null ? "" : "-" + parent.getTf_text()));
				allPath.add(p);
				pmodule.getCanNavigateParentPaths(allPath, p);
			}
		}
	}

	
	@JsonIgnore
	public void getNavigateParentPaths(List<_ModuleGridNavigate> allPath, _ModuleGridNavigate parent) {
		// List<List<String>> result = new ArrayList<List<String>>();
		if (getNavigateParents().size() > 0) {
			// 如果这个节点有父接点，那么把这个删了，要加入的父接点－－祖父接点
			allPath.remove(parent);
			for (_Module pmodule : getNavigateParents()) {
				_ModuleGridNavigate p = new _ModuleGridNavigate(pmodule.getTf_moduleName()
						+ (parent == null ? "" : "--" + parent.getTf_fields()), pmodule.getTf_title()
						+ (parent == null ? "" : "-" + parent.getTf_text()));
				allPath.add(p);
				pmodule.getNavigateParentPaths(allPath, p);
			}
		}
	}

	
	@JsonIgnore
	public void getParentPaths(List<String> allPath, String parent) {
		// List<List<String>> result = new ArrayList<List<String>>();
		if (getParents().size() > 0) {
			// 如果这个节点有父接点，那么把这个删了，要加入的父接点－－祖父接点
			allPath.remove(parent);
			for (_Module pmodule : getParents()) {
				String p = pmodule.getTf_moduleName() + (parent == null ? "" : "--" + parent);
				allPath.add(p);
				pmodule.getParentPaths(allPath, p);
			}
		}
	}

	
	@JsonIgnore
	public Map<String, _Module> getAllParentsMap() {
		Map<String, _Module> result = new HashMap<String, _Module>();
		for (_Module m : getParents()) {
			result.put(m.getTf_moduleName(), m);
			result.putAll(m.getAllParentsMap());
		}
		return result;
	}

	
	@JsonIgnore
	public List<_Module> getAllParentsList() {
		List<_Module> result = new ArrayList<_Module>();
		for (_Module m : getParents()) {
			result.add(m);
		}
		for (_Module m : getParents()) {
			List<_Module> ms = m.getAllParentsList();
			for (_Module mm : ms)
				if (!result.contains(mm))
					result.add(mm);
		}
		return result;
	}

	
	@JsonIgnore
	public List<_Module> getAllChildsList() {
		List<_Module> result = new ArrayList<_Module>();
		for (_Module m : getChilds()) {
			result.add(m);
		}
		for (_Module m : getChilds()) {
			List<_Module> ms = m.getAllChildsList();
			for (_Module mm : ms)
				if (!result.contains(mm))
					result.add(mm);
		}
		return result;
	}

	// 根据模块 as name 号取得模块定义
	public _Module getModuleWithAsName(String name) {
		for (_Module module : getParents())
			if (module.getTableAsName().equals(name))
				return module;
		for (_Module module : getParentOneToOnes())
			if (module.getTableAsName().equals(name))
				return module;

		return null;
	}

	// 根据模块名称，返回父模块定义
	public _Module getParentModuleWithName(String name) {
		for (_Module pm : getParents())
			if (pm.getTf_moduleName().equals(name))
				return pm;
		return null;
	}

	public _ModuleGridScheme getGridFieldsSchemeWithName(String schemaName) {
		for (int i = 0; i < moduleGridSchemes.size(); i++) {
			if (moduleGridSchemes.get(i).getTf_schemeName().equals(schemaName))
				return moduleGridSchemes.get(i);
		}
		return null;
	}

	public _ModuleGridScheme getGridFieldsSchemeWithOrder(Integer id) {
		for (int i = 0; i < moduleGridSchemes.size(); i++) {
			if (moduleGridSchemes.get(i).getTf_schemeOrder().equals(id))
				return moduleGridSchemes.get(i);
		}
		return null;
	}

	public String getTableAsName() {
		return "_t" + tf_moduleId;
	}

	public static String IMGPATH = null;

	public String getIconURL() {
		if (IMGPATH == null) {
			IMGPATH = _Module.class.getResource("/").getPath().replace("%20", " ");
			IMGPATH = IMGPATH.substring(0, IMGPATH.indexOf("WEB-INF")) + "images" + File.separator
					+ "module" + File.separator;
		}
		if (FileOperate.fileExists(IMGPATH + tf_moduleName + ".png"))
			return ModuleConstants.MENUICONPATH + tf_moduleName + ".png";
		else
			return null;
	}

	public String getTf_moduleId() {
		return tf_moduleId;
	}

	public void setTf_moduleId(String tf_moduleId) {
		this.tf_moduleId = tf_moduleId;
	}

	public String getTf_moduleName() {
		return tf_moduleName;
	}

	// 如果modulename没有前缀_,那就就加一个用于生成 tf_ （modulename）
	public String getTf_moduleNameWithPre() {
		if (tf_moduleName.startsWith("_"))
			return tf_moduleName;
		else
			return "_" + tf_moduleName;
	}

	public void setTf_moduleName(String tf_moduleName) {
		this.tf_moduleName = tf_moduleName;
	}

	public String getTf_title() {
		return tf_title;
	}

	public String shortnameOrTitle() {
		if (tf_shortname == null || tf_shortname.length() == 0)
			return tf_title;
		else
			return tf_shortname;
	}

	public void setTf_title(String tf_title) {
		this.tf_title = tf_title;
	}

	public String getTf_shortname() {
		return tf_shortname;
	}

	public void setTf_shortname(String tf_shortname) {
		this.tf_shortname = tf_shortname;
	}

	public String getTf_englishname() {
		return tf_englishname;
	}

	public void setTf_englishname(String tf_englishname) {
		this.tf_englishname = tf_englishname;
	}

	public String getTf_primaryKey() {
		return tf_primaryKey;
	}

	public void setTf_primaryKey(String tf_primaryKey) {
		this.tf_primaryKey = tf_primaryKey;
	}

	public String getTf_nameFields() {
		return tf_nameFields;
	}

	public void setTf_nameFields(String tf_nameFields) {
		this.tf_nameFields = tf_nameFields;
	}

	public String getTf_description() {
		return tf_description;
	}

	public void setTf_description(String tf_description) {
		this.tf_description = tf_description;
	}

	public String getTf_requestMapping() {
		return tf_requestMapping;
	}

	public void setTf_requestMapping(String tf_requestMapping) {
		this.tf_requestMapping = tf_requestMapping;
	}

	public String getTf_iconURL() {
		return tf_iconURL;
	}

	public void setTf_iconURL(String tf_iconURL) {
		this.tf_iconURL = tf_iconURL;
	}

	public Boolean getTf_isInlineOper() {
		return tf_isInlineOper;
	}

	public void setTf_isInlineOper(Boolean tf_isInlineOper) {
		this.tf_isInlineOper = tf_isInlineOper;
	}

	public Boolean getTf_isEnable() {
		return tf_isEnable == null ? false : tf_isEnable;
	}

	public void setTf_isEnable(Boolean tf_isEnable) {
		this.tf_isEnable = tf_isEnable;
	}

	public Boolean getTf_hasBrowse() {
		return tf_hasBrowse == null ? false : tf_hasBrowse;
	}

	public void setTf_hasBrowse(Boolean tf_hasBrowse) {
		this.tf_hasBrowse = tf_hasBrowse;
	}

	public Boolean getTf_hasInsert() {
		return tf_hasInsert == null ? false : tf_hasInsert;
	}

	public void setTf_hasInsert(Boolean tf_hasInsert) {
		this.tf_hasInsert = tf_hasInsert;
	}

	public Boolean getTf_hasEdit() {
		return tf_hasEdit == null ? false : tf_hasEdit;
	}

	public void setTf_hasEdit(Boolean tf_hasEdit) {
		this.tf_hasEdit = tf_hasEdit;
	}

	public Boolean getTf_hasDelete() {
		return tf_hasDelete == null ? false : tf_hasDelete;
	}

	public void setTf_hasDelete(Boolean tf_hasDelete) {
		this.tf_hasDelete = tf_hasDelete;
	}

	public Boolean getTf_hasExec() {
		return tf_hasExec == null ? false : tf_hasExec;
	}

	public void setTf_hasExec(Boolean tf_hasExec) {
		this.tf_hasExec = tf_hasExec;
	}

	public Boolean getTf_hasAuditing() {
		return tf_hasAuditing == null ? false : tf_hasAuditing;
	}

	public void setTf_hasAuditing(Boolean tf_hasAuditing) {
		this.tf_hasAuditing = tf_hasAuditing;
	}

	public Boolean getTf_hasApprove() {
		return tf_hasApprove == null ? false : tf_hasApprove;
	}

	public void setTf_hasApprove(Boolean tf_hasApprove) {
		this.tf_hasApprove = tf_hasApprove;
	}

	public Boolean getTf_hasPayment() {
		return tf_hasPayment == null ? false : tf_hasPayment;
	}

	public void setTf_hasPayment(Boolean tf_hasPayment) {
		this.tf_hasPayment = tf_hasPayment;
	}

	public Boolean getTf_hasAddition() {
		return tf_hasAddition == null ? false : tf_hasAddition;
	}

	public void setTf_hasAddition(Boolean tf_hasAddition) {
		this.tf_hasAddition = tf_hasAddition;
	}

	public String getTf_remark() {
		return tf_remark;
	}

	public void setTf_remark(String tf_remark) {
		this.tf_remark = tf_remark;
	}

	public _ModuleGroup getTf_ModuleGroup() {
		return tf_ModuleGroup;
	}

	public void setTf_ModuleGroup(_ModuleGroup tf_ModuleGroup) {
		this.tf_ModuleGroup = tf_ModuleGroup;
	}

	public List<_ModuleField> getModuleFields() {
		return moduleFields;
	}

	public void setModuleFields(List<_ModuleField> moduleFields) {
		this.moduleFields = moduleFields;
	}

	public List<_ModuleFormScheme> getModuleFormSchemes() {
		return moduleFormSchemes;
	}

	public void setModuleFormSchemes(List<_ModuleFormScheme> moduleFormSchemes) {
		this.moduleFormSchemes = moduleFormSchemes;
	}

	public List<_ModuleGridScheme> getModuleGridSchemes() {
		return moduleGridSchemes;
	}

	public void setModuleGridSchemes(List<_ModuleGridScheme> moduleGridSchemes) {
		this.moduleGridSchemes = moduleGridSchemes;
	}

	public List<_ModuleDetailScheme> getModuleDetailSchemes() {
		return moduleDetailSchemes;
	}

	public void setModuleDetailSchemes(List<_ModuleDetailScheme> moduleDetailSchemes) {
		this.moduleDetailSchemes = moduleDetailSchemes;
	}

	public List<_ModuleAdditionField> getModuleAdditionFields() {
		return moduleAdditionFields;
	}

	public void setModuleAdditionFields(List<_ModuleAdditionField> moduleAdditionFields) {
		this.moduleAdditionFields = moduleAdditionFields;
	}

	public List<_Module> _getParents() {
		return parents;
	}

	public List<_Module> getParents() {
		if (parents == null)
			parents = new ArrayList<_Module>();
		return parents;
	}

	public void setParents(List<_Module> parents) {
		this.parents = parents;
	}

	public List<_Module> getNavigateParents() {
		if (navigateParents == null)
			navigateParents = new ArrayList<_Module>();
		return navigateParents;
	}

	public void setNavigateParents(List<_Module> navigateParents) {
		this.navigateParents = navigateParents;
	}

	public List<_Module> getChilds() {
		if (childs == null)
			childs = new ArrayList<_Module>();
		return childs;
	}

	public List<String> getChildNames() {
		if (childNames == null)
			childNames = new ArrayList<String>();
		return childNames;
	}

	public void setChildNames(List<String> childNames) {
		this.childNames = childNames;
	}

	public void setChilds(List<_Module> childs) {
		this.childs = childs;
	}

	public List<_ModuleAdditionFunction> getModuleAdditions() {
		return moduleAdditions;
	}

	public void setModuleAdditions(List<_ModuleAdditionFunction> moduleAdditions) {
		this.moduleAdditions = moduleAdditions;
	}

	public Map<String, String> getIdNameMap() {
		return idNameMap;
	}

	public void setIdNameMap(Map<String, String> idNameMap) {
		this.idNameMap = idNameMap;
	}

	public String getTf_defaultOrderField() {
		return tf_defaultOrderField;
	}

	public void setTf_defaultOrderField(String tf_defaultOrderField) {
		this.tf_defaultOrderField = tf_defaultOrderField;
	}

	public String getTf_codeLevel() {
		return tf_codeLevel;
	}

	public void setTf_codeLevel(String tf_codeLevel) {
		this.tf_codeLevel = tf_codeLevel;
	}

	public Boolean isCodeLevel() {
		return (tf_codeLevel != null && tf_codeLevel.length() > 0);
	}

	public Boolean getTf_canLimit() {
		return tf_canLimit == null ? false : tf_canLimit;
	}

	public void setTf_canLimit(Boolean tf_canLimit) {
		this.tf_canLimit = tf_canLimit;
	}

	public List<_ModuleGridNavigate> getModuleGridNavigates() {
		return moduleGridNavigates;
	}

	public void setModuleGridNavigates(List<_ModuleGridNavigate> moduleGridNavigates) {
		this.moduleGridNavigates = moduleGridNavigates;
	}

	public List<_ModuleExcelReport> getModuleExcelReports() {
		return moduleExcelReports;
	}

	public void setModuleExcelReports(List<_ModuleExcelReport> moduleExcelReports) {
		this.moduleExcelReports = moduleExcelReports;
	}

	public List<_ModuleExcelRecordAdd> getModuleExcelRecordAdds() {
		return moduleExcelRecordAdds;
	}

	public void setModuleExcelRecordAdds(List<_ModuleExcelRecordAdd> moduleExcelRecordAdds) {
		this.moduleExcelRecordAdds = moduleExcelRecordAdds;
	}

	public List<_PrintScheme> getRecordPrintSchemes() {
		return recordPrintSchemes;
	}

	public void setRecordPrintSchemes(List<_PrintScheme> recordPrintSchemes) {
		this.recordPrintSchemes = recordPrintSchemes;
	}

	public List<_ModuleApprove> getModuleApproves() {
		return moduleApproves;
	}

	public void setModuleApproves(List<_ModuleApprove> moduleApproves) {
		this.moduleApproves = moduleApproves;
	}

	public Boolean isModuleChildOneToOne(String moduleName) {
		if (childOneToOnes == null)
			return false;
		for (_Module m : childOneToOnes)
			if (m.getTf_moduleName().equals(moduleName))
				return true;
		return false;
	}

	public Boolean isModuleParentOneToOne(String moduleName) {
		if (parentOneToOnes == null)
			return false;
		for (_Module m : parentOneToOnes)
			if (m.getTf_moduleName().equals(moduleName))
				return true;
		return false;
	}

	public List<_Module> _getParentOneToOnes() {
		return parentOneToOnes;
	}	
	
	public List<_Module> getParentOneToOnes() {
		if (parentOneToOnes == null)
			parentOneToOnes = new ArrayList<_Module>();
		return parentOneToOnes;
	}

	public void setParentOneToOnes(List<_Module> parentOneToOnes) {
		this.parentOneToOnes = parentOneToOnes;
	}

	public List<_Module> _getChildOneToOnes() {
		return childOneToOnes;
	}
	
	public List<_Module> getChildOneToOnes() {
		if (childOneToOnes == null)
			childOneToOnes = new ArrayList<_Module>();
		return childOneToOnes;
	}

	public void setChildOneToOnes(List<_Module> childOneToOnes) {
		this.childOneToOnes = childOneToOnes;
	}

	public String getTf_tableName() {
		return tf_tableName == null || tf_tableName.length() == 0 ? tf_moduleName : tf_tableName;
	}

	public void setTf_tableName(String tf_tableName) {
		this.tf_tableName = tf_tableName;
	}

	public String getTf_linkedModule() {
		return tf_linkedModule;
	}

	public void setTf_linkedModule(String tf_linkedModule) {
		this.tf_linkedModule = tf_linkedModule;
	}

	public Boolean getTf_allowInsertExcel() {
		return tf_allowInsertExcel;
	}

	public void setTf_allowInsertExcel(Boolean tf_allowInsertExcel) {
		this.tf_allowInsertExcel = tf_allowInsertExcel;
	}

	public Boolean getTf_allowEditExcel() {
		return tf_allowEditExcel;
	}

	public void setTf_allowEditExcel(Boolean tf_allowEditExcel) {
		this.tf_allowEditExcel = tf_allowEditExcel;
	}

	public Boolean getTf_hasChart() {
		return tf_hasChart;
	}

	public void setTf_hasChart(Boolean tf_hasChart) {
		this.tf_hasChart = tf_hasChart;
	}

	public String getTf_codeField() {
		return tf_codeField;
	}

	public void setTf_codeField(String tf_codeField) {
		this.tf_codeField = tf_codeField;
	}

	public String getTf_orderField() {
		return tf_orderField;
	}

	public void setTf_orderField(String tf_orderField) {
		this.tf_orderField = tf_orderField;
	}

	public String getTf_dateField() {
		return tf_dateField;
	}

	public void setTf_dateField(String tf_dateField) {
		this.tf_dateField = tf_dateField;
	}

	public String getTf_yearfield() {
		return tf_yearfield;
	}

	public void setTf_yearfield(String tf_yearfield) {
		this.tf_yearfield = tf_yearfield;
	}

	public String getTf_monthField() {
		return tf_monthField;
	}

	public void setTf_monthField(String tf_monthField) {
		this.tf_monthField = tf_monthField;
	}

	public String getTf_seasonField() {
		return tf_seasonField;
	}

	public void setTf_seasonField(String tf_seasonField) {
		this.tf_seasonField = tf_seasonField;
	}

	public String getTf_homePageTag() {
		return tf_homePageTag;
	}

	public void setTf_homePageTag(String tf_homePageTag) {
		this.tf_homePageTag = tf_homePageTag;
	}

	public String getTf_titleTpl() {
		return tf_titleTpl;
	}

	public void setTf_titleTpl(String tf_titleTpl) {
		this.tf_titleTpl = tf_titleTpl;
	}

	public String getTf_fileField() {
		return tf_fileField;
	}

	public void setTf_fileField(String tf_fileField) {
		this.tf_fileField = tf_fileField;
	}

	public Boolean getTf_isSystem() {
		return tf_isSystem;
	}

	public void setTf_isSystem(Boolean tf_isSystem) {
		this.tf_isSystem = tf_isSystem;
	}

	public List<_ModuleFieldConstraint> getModuleFieldConstraints() {
		return moduleFieldConstraints;
	}

	public void setModuleFieldConstraints(List<_ModuleFieldConstraint> moduleFieldConstraints) {
		this.moduleFieldConstraints = moduleFieldConstraints;
	}

	public Integer getTf_searchCondOrder() {
		return tf_searchCondOrder;
	}

	public void setTf_searchCondOrder(Integer tf_searchCondOrder) {
		this.tf_searchCondOrder = tf_searchCondOrder;
	}

	public List<GroupFieldDefine> getGroupFieldDefines() {
		return groupFieldDefines;
	}

	public void setGroupFieldDefines(List<GroupFieldDefine> groupFieldDefines) {
		this.groupFieldDefines = groupFieldDefines;
	}

	public List<_ModuleSubToolbar> getModuleSubToolbar() {
		return moduleSubToolbar;
	}

	public void setModuleSubToolbar(List<_ModuleSubToolbar> moduleSubToolbar) {
		this.moduleSubToolbar = moduleSubToolbar;
	}

}
